package main

import (
	"fmt"
	"io"
	"k8s.io/apimachinery/pkg/api/resource"
	"os"
)

func main() {
	devicePath := ""
	dev, err := os.Open(devicePath)
	if err != nil {
		fmt.Printf("unable to open device %q: %w", devicePath, err)
	}
	defer dev.Close()

	end, err := dev.Seek(0, io.SeekEnd)
	if err != nil {
		fmt.Printf("failed to detect size of %q: %w", devicePath, err)
	}

	capacity := resource.NewQuantity(end, resource.BinarySI)

	println(capacity)
}
